package net.oktaeder.office.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

public class Employee {

	private static Log log = LogFactory.getLog(Employee.class);
	private String name;
	private String PIN;
	private int salary;
	private Date birthDate;
	
	private ArrayList<WorkOrder> orders;
	
	/*
	 * Default constructor
	 */
	public Employee() {
		log.trace("Creating an instance");
		orders = new ArrayList<WorkOrder>();
	}
	
	/**
	 * Get name of the employee
	 * 
	 * @return Name of the employee as String
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Set name of the employee
	 * 
	 * @param name Name of the employee
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Get personal identification code of the person.
	 * This code should be unique for each person
	 * 
	 * @return Personal Identification Code
	 */
	public String getPIN() {
		return PIN;
	}
	
	/**
	 * Set personal identification code of the person
	 * This code should be unique for each person
	 * Currently there are no checks for this in place
	 * 
	 * @param pin Personal Identification Code to set
	 */
	public void setPIN(String pin) {
		PIN = pin;
	}
	
	/**
	 * Get salary of the person
	 * 
	 * @return Salary of the person
	 */
	public int getSalary() {
		return salary;
	}
	
	/**
	 * Set salary of the person
	 * 
	 * @param salary Salary to set
	 */
	public void setSalary(int salary) {
		this.salary = salary;
	}
	
	/**
	 * Add work order object for the person
	 * Person will start working on this order on the
	 * next update of the simulation
	 * 
	 * @param order Order to set
	 * @throws IllegalArgumentException if order is null
	 */
	public void addOrder(WorkOrder order) throws IllegalArgumentException {
			
		if (order == null) {
			throw new IllegalArgumentException("Work order can not be null");
		}
		orders.add(order);
	}
	
	/**
	 * Get Iterator for current work orders of the person
	 * 
	 * @return Iterator of all work orders of the person
	 */
	public Iterator<WorkOrder> getOrderIterator() {
		return orders.iterator();
	}
	
	/**
	 * Get birth date of the person
	 * 
	 * @return Birthdate
	 */
	public Date getBirthDate() {
		return birthDate;
	}
	
	/**
	 * Set birth date of the person
	 * 
	 * @param birthDate
	 */
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
}